VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmCxCEstadoCuentaSaloin 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Consulta de descargos Saloin"
   ClientHeight    =   6660
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11010
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6660
   ScaleWidth      =   11010
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmbEdoCtaSaloin 
      BackColor       =   &H00F7F5F3&
      Caption         =   "&Cerrar"
      Height          =   330
      Index           =   1
      Left            =   1395
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   6210
      Width           =   1230
   End
   Begin VB.CommandButton cmbEdoCtaSaloin 
      BackColor       =   &H00F7F5F3&
      Caption         =   "&Imprimir"
      Height          =   330
      Index           =   0
      Left            =   90
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   6210
      Width           =   1230
   End
   Begin MSComctlLib.ListView lsvEdoCtaSaloin 
      Height          =   3840
      Left            =   0
      TabIndex        =   1
      Top             =   1845
      Width           =   10995
      _ExtentX        =   19394
      _ExtentY        =   6773
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Appearance      =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Object.Width           =   0
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   1
         SubItemIndex    =   1
         Text            =   "Solicitud / Contrato"
         Object.Width           =   3528
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   1
         SubItemIndex    =   2
         Text            =   "Fecha"
         Object.Width           =   2469
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   1
         SubItemIndex    =   3
         Text            =   "Monto"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.Label lblMontoDisponible 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "$ 0.00"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   285
      Left            =   3870
      TabIndex        =   9
      Top             =   900
      Width           =   1995
   End
   Begin VB.Label lblMontoDescargos 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "$ 0.00"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   285
      Left            =   3870
      TabIndex        =   8
      Top             =   540
      Width           =   1995
   End
   Begin VB.Label lblMontoSaloin 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "$ 0.00"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   3870
      TabIndex        =   7
      Top             =   135
      Width           =   1995
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "MONTO DISPONIBLE"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   270
      Index           =   2
      Left            =   135
      TabIndex        =   6
      Top             =   900
      Width           =   2310
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "MONTO TOTAL EN DESCARGOS"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   270
      Index           =   1
      Left            =   135
      TabIndex        =   5
      Top             =   585
      Width           =   3555
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "MONTO SALOIN"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   11.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   270
      Index           =   0
      Left            =   135
      TabIndex        =   4
      Top             =   135
      Width           =   1755
   End
   Begin VB.Label lblEdoCtaSaloin 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "DETALLE DE DESCARGOS"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   240
      Index           =   4
      Left            =   135
      TabIndex        =   0
      Top             =   1485
      Width           =   2475
   End
   Begin VB.Line Line1 
      BorderColor     =   &H00CD9F92&
      BorderWidth     =   2
      Index           =   1
      X1              =   -45
      X2              =   12910
      Y1              =   1800
      Y2              =   1800
   End
End
Attribute VB_Name = "frmCxCEstadoCuentaSaloin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Activate()
    gprocEspera False
End Sub
Private Sub Form_Load()
    gprocEspera True
    Dim rstSaloinValTomados As New ADODB.Recordset
    Dim rstSaloinDescargos As New ADODB.Recordset
    Dim rstValorSaloin As New ADODB.Recordset
    Dim Itm As ListItem
    Dim dblTotalDescargos As Double
    Dim dblValorSaloin As Double
    
    lsvEdoCtaSaloin.ListItems.Clear
    'Valor total del producto SALOIN
    dblValorSaloin = 0
    rstValorSaloin.Open "SELECT SUM(Cantidad * Precio_Unitario) AS Total " _
        & "From Safc_Ventas..venDetalle_de_Ventas WHERE Codigo_Contrato = '" & frmCxCEstadoCuenta.txtEdoCta & "' AND " _
        & "Codigo_Producto = 'SER-SALOIN'", gCnCXC, adOpenStatic, adLockOptimistic, adCmdText
    With rstValorSaloin
        If Not .EOF Then
            dblValorSaloin = IIf(IsNull(.Fields(0)), 0, .Fields(0))
            lblMontoSaloin = Lee_NumD(.Fields(0))
        Else
            lblMontoSaloin = Lee_NumD(0)
        End If
        .Close
    End With
    Set rstValorSaloin = Nothing
    
    'Buscar valores tomados
    dblTotalDescargos = 0
    rstSaloinValTomados.Open "SELECT Codigo_Contrato, Fecha_Toma, ValorTomado " _
        & "FROM Safc_Ventas..venValor_TomadoSaloin " _
        & "WHERE Codigo_ContratoTomado_Saloin = '" & frmCxCEstadoCuenta.txtEdoCta & "'", gCnCXC, adOpenStatic, adLockOptimistic, adCmdText
    
    With rstSaloinValTomados
        While Not .EOF
            Set Itm = lsvEdoCtaSaloin.ListItems.Add(, , "", , 0)
            Itm.SubItems(1) = Lee_Campo(.Fields(0))
            Itm.SubItems(2) = Lee_Fecha(.Fields(1))
            Itm.SubItems(3) = Lee_NumD(.Fields(2))
            dblTotalDescargos = dblTotalDescargos + .Fields(2)
            .MoveNext
        Wend
        .Close
    End With
    Set rstSaloinValTomados = Nothing
    
    'Buscar descargos
    rstSaloinDescargos.Open "SELECT No_Solicitud, FechaServ, ValorServ " _
        & "FROM Safc_Ventas..VenDescargos_Saloin " _
        & "WHERE Vta_Codigo = '" & frmCxCEstadoCuenta.txtEdoCta & "'", gCnCXC, adOpenStatic, adLockOptimistic, adCmdText
    
    With rstSaloinDescargos
        While Not .EOF
            Set Itm = lsvEdoCtaSaloin.ListItems.Add(, , "", , 0)
            Itm.SubItems(1) = Lee_Campo(.Fields(0))
            Itm.SubItems(2) = Lee_Fecha(.Fields(1))
            Itm.SubItems(3) = Lee_NumD(.Fields(2))
            dblTotalDescargos = dblTotalDescargos + .Fields(2)
            .MoveNext
        Wend
        .Close
    End With
    Set rstSaloinDescargos = Nothing
    
    lblMontoDescargos = Lee_NumD(dblTotalDescargos)
    lblMontoDisponible = Lee_NumD(dblValorSaloin - dblTotalDescargos)
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Set frmCxCEstadoCuentaRecibos = Nothing
End Sub
Private Sub cmbEdoCtaSaloin_Click(Index As Integer)
    If Index = 0 Then
    Else
        Unload frmCxCEstadoCuentaSaloin
    End If
End Sub
